'\" te
.\" Copyright (c) 2004, Sun Microsystems, Inc., All Rights Reserved
.\" The contents of this file are subject to the terms of the Common Development and Distribution License (the "License").  You may not use this file except in compliance with the License.
.\" You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE or http://www.opensolaris.org/os/licensing.  See the License for the specific language governing permissions and limitations under the License.
.\" When distributing Covered Code, include this CDDL HEADER in each file and include the License file at usr/src/OPENSOLARIS.LICENSE.  If applicable, add the following below this CDDL HEADER, with the fields enclosed by brackets "[]" replaced with your own identifying information: Portions Copyright [yyyy] [name of copyright owner]
.TH USB_PIPE_GET_STATE 9F "Sep 16, 2016"
.SH NAME
usb_pipe_get_state \- Return USB pipe state
.SH SYNOPSIS
.nf
#include <sys/usb/usba.h>



\fBint\fR \fBusb_pipe_get_state\fR(\fBusb_pipe_handle_t\fR \fIpipe_handle\fR,
     \fBusb_pipe_state_t *\fR\fIpipe_state\fR, \fBusb_flags_t\fR \fIusb_flags\fR);
.fi

.SH INTERFACE LEVEL
illumos DDI specific (illumos DDI)
.SH PARAMETERS
.ne 2
.na
\fB\fIpipe_handle\fR\fR
.ad
.RS 15n
Handle of the pipe to retrieve the state.
.RE

.sp
.ne 2
.na
\fB\fIpipe_state\fR\fR
.ad
.RS 15n
Pointer to where pipe state is returned.
.RE

.sp
.ne 2
.na
\fB\fIusb_flags\fR\fR
.ad
.RS 15n
No flags are recognized. Reserved for future expansion.
.RE

.SH DESCRIPTION
The \fBusb_pipe_get_state()\fR function retrieves the state of the pipe
referred to by \fIpipe_handle\fR into the location pointed to by
\fIpipe_state\fR.
.sp
.LP
Possible pipe states are:
.sp
.ne 2
.na
\fBUSB_PIPE_STATE_CLOSED\fR
.ad
.RS 26n
Pipe is closed.
.RE

.sp
.ne 2
.na
\fBUSB_PIPE_STATE_ACTIVE\fR
.ad
.RS 26n
Pipe is active and can send/receive data. Polling is active for isochronous and
interrupt pipes.
.RE

.sp
.ne 2
.na
\fBUSB_PIPE_STATE_IDLE\fR
.ad
.RS 26n
Polling is stopped for isochronous and interrupt-IN pipes.
.RE

.sp
.ne 2
.na
\fBUSB_PIPE_STATE_ERROR\fR
.ad
.RS 26n
An error occurred. Client must call \fBusb_pipe_reset()\fR. Note that this
status is not seen by a client driver if USB_ATTRS_AUTOCLEARING is set in the
request attributes.
.RE

.sp
.ne 2
.na
\fBUSB_PIPE_STATE_CLOSING\fR
.ad
.RS 26n
Pipe is being closed. Requests are being drained from the pipe and other
cleanup is in progress.
.RE

.SH RETURN VALUES
.ne 2
.na
\fBUSB_SUCCESS\fR
.ad
.RS 20n
Pipe state returned in second argument.
.RE

.sp
.ne 2
.na
\fBUSB_INVALID_ARGS\fR
.ad
.RS 20n
Pipe_state argument is \fBNULL\fR.
.RE

.sp
.ne 2
.na
\fBUSB_INVALID_PIPE\fR
.ad
.RS 20n
Pipe_handle argument is \fBNULL\fR.
.RE

.SH CONTEXT
May be called from user, kernel or interrupt context.
.SH EXAMPLES
.in +2
.nf
    usb_pipe_handle_t pipe;
    usb_pipe_state_t state;

    /* Recover if the pipe is in an error state. */
    if ((usb_pipe_get_state(pipe, &state, 0) == USB_SUCCESS) &&
        (state == USB_PIPE_STATE_ERROR)) {
            cmn_err (CE_WARN, "%s%d: USB Pipe error.",
                ddi_driver_name(dip), ddi_get_instance(dip));
            do_recovery();
    }

.fi
.in -2

.SH ATTRIBUTES
See \fBattributes\fR(7) for descriptions of the following attributes:
.sp

.sp
.TS
box;
c | c
l | l .
ATTRIBUTE TYPE	ATTRIBUTE VALUE
_
Architecture	PCI-based systems
_
Interface stability	Committed
.TE

.SH SEE ALSO
.BR attributes (7),
.BR usb_clr_feature (9F),
.BR usb_get_cfg (9F),
.BR usb_get_status (9F),
.BR usb_pipe_close (9F),
.BR usb_pipe_ctrl_xfer (9F),
.BR usb_pipe_reset (9F),
.BR usb_pipe_xopen (9F)
